package com.stx.boke.base.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public final class jdbcOracleUtil {
	private static String url = "jdbc:oracle:thin:@localhost:1521:XE";
	private static String username = "stx";
	private static String password= "stx";
	   


	static {//加载驱动，只执行set
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		} catch (ClassNotFoundException e) {
			throw new ExceptionInInitializerError(e);
		}
	}

	public static Connection getConnection() throws SQLException {
		return DriverManager.getConnection(url, username, password);
	}

	public static void free(ResultSet rs, Statement st, Connection conn)
			throws SQLException {
		try {
			if (rs != null )
				rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				if (st != null )//&& st.isClosed()
					st.close();
			} catch (SQLException e) {
				e.printStackTrace();
			} finally {
				if (conn != null )//&& conn.isClosed()
					try {
						conn.close();
					} catch (SQLException e) {
						e.printStackTrace();
					}
			}
		}
	}
}
